<?php

require_once('trim.php');

if ($argc < 3) {
	echo 'USAGE: php '.$argv[0].' <tr.im username> <tr.im password>' . "\n";
	exit();
}

$trim = new TrimAPI($argv[1], $argv[2], '', true);

try {
	
	$urls = $trim->urls();
	
	// header
	$keys = array_keys($urls[0]);
	echo '"' . implode('","', $keys) . '"' . "\n";
	
	// output each url
	foreach($urls as $url) {
		$cells = array();
		foreach ($keys as $k) {
			$cells[] = '"' . str_replace('"', '\"', $url[$k]) . '"';
		}
		echo implode(',', $cells) . "\n";
	}
	
} catch (Exception $e) {
	echo 'Exception: ' . $e->getMessage() . "\n";
}

?>